#!/usr/bin/python3
# -*- coding: utf-8 -*-


import pandas as pd
import numpy as np
import talib

eps = 1e-8

def signal(*args):
    # Mm指标
    
    df = args[0]
    n = args[1]
    factor_name = args[2]

    ma_fast = df['close'].rolling(n, min_periods=1).mean()
    ma_slow = df['close'].rolling(5*n, min_periods=1).mean()
    df[factor_name] = ma_fast / (ma_slow + eps) - 1

    return df
